
ShowWebsiteList(playerid)
{
	format(query, sizeof(query), "SELECT WebAdress FROM webpages", PlayerInfo[playerid][pSQLID]);
	mysql_query(query, THREAD_WEBSITE_LIST, playerid);
	return 1;
}


ShowCharactersMenu(playerid)
{
	// Select the character unique ID and its name from the database
	format(query, sizeof(query), "SELECT id,name FROM characters WHERE pid = %i LIMIT 0,5", PlayerInfo[playerid][pSQLID]);
	mysql_query(query, THREAD_CHARS_MENU, playerid);
	return 1;
}

ShowEmails(playerid)
{
    format(query, sizeof(query), "SELECT SQLid, EmailSubject FROM email WHERE SendingTo =%i", PlayerInfo[playerid][cSQLID]);
    mysql_query(query, THREAD_EMAILS, playerid);
	return true;
}

stock IsNumeric(const stringg[])
{
	for(new i = 0; i < strlen(stringg); i++)
	{
		if(stringg[i] > '9' || stringg[i] < '0') return 0;
	}
	return 1;
}

stock ShowDescMenu(playerid)
{
	if(GetPVarType(playerid, "AGE") == PLAYER_VARTYPE_NONE) tmp = "{FF6347}- Age\n";
	else tmp = "{9ACD32}- Age\n";
	if(GetPVarType(playerid, "SKIN") == PLAYER_VARTYPE_NONE) strcat(tmp, "{FF6347}- Skin\n");
	else strcat(tmp, "{9ACD32}- Skin\n");
	strcat(tmp, "- Delete character\n- Proceed");
	ShowPlayerDialog(playerid, DIALOG_DESC_CHAR, DIALOG_STYLE_LIST, "Options menu - Your character", tmp, "Select", "Back");
	return 1;
}

stock dialog_CreateChar(playerid)
{
	tmp = "Type in your desired character name!\nThe name must stay between 6 and 24 characters.\nIt can only contain characters A-Z, a-z and a space!\nExample: ";
	switch(random(4))
	{
		case 0: strcat(tmp, "Andrew Jones");
		case 1: strcat(tmp, "John Roosevelt");
		case 2: strcat(tmp, "Nicole Sheridan");
		case 3: strcat(tmp, "James Corleone");
	}
	ShowPlayerDialog(playerid, DIALOG_CREATE_CHAR, DIALOG_STYLE_INPUT, "Create a new character", tmp, "Create", "Cancel");
	return true;
}


stock SendLocalMessage(playerid, msg[], Float:MessageRange, color)
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ;
    GetPlayerPos(playerid, PlayerX, PlayerY, PlayerZ);
    foreach(Player, player)
	{
        if(GetPlayerVirtualWorld(playerid) ==  GetPlayerVirtualWorld(player))
		{
            if(IsPlayerInRangeOfPoint(player, MessageRange, PlayerX, PlayerY,PlayerZ))
			{
                SendClientMessage(player, color, msg);
            }
        }
    }
}

stock IsPlayerSpawned(playerid)
{
	if(GetPVarInt(playerid, "SPAWNED") == 0) return false;
	return true;
}

stock ShowSettingsMenu(playerid)
{
	tmp = "";
	if(!GetPVarInt(playerid, "AUTO_LOG"))
	{
		strcat(tmp, "Auto Login - {FF6347}DISABLED");
	}
	else
	{
		strcat(tmp, "Auto Login - {FFFD96}ENABLED");
	}
	ShowPlayerDialog(playerid, DIALOG_SETTINGS, DIALOG_STYLE_LIST, "Account Settings", tmp, "Select", "Back");
	return true;
}

stock ClearChat(playerid)
{
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
	SendClientMessage(playerid, 0x0DCC1DFF, " ");
}

stock LoadServer(playerid)
{
    LoadVehicles();
    ManualVehicleEngineAndLights();
}

stock CreateVehicleEx(playerid, model, price, buyable, rent, faction, color1, color2)
{
	new string[512];
    new Float:x;
    new Float:y;
    new Float:z;
    new Float:a;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    GetXYInFrontOfPlayer(playerid, x, y, 2.0);
    CreateVehicle(model, x, y, z, a, color1, color2, 9999999999999999999999999);

    Itter_Add(Vehicles,Iter_Count(Vehicles)+1);

	// generate license plate
    for(new i = 0; i <= 5; i++){ format(VehicleInfo[Iter_Count(Vehicles)][vPlate], 30, "%s%s",VehicleInfo[Iter_Count(Vehicles)][vPlate], Letters[random(sizeof(Letters))][0]); }

    format(string, sizeof(string), "INSERT INTO vehicles (`Model`,`vPos`,`vPos2`, `vPos3`, `vPos4`, `color1`, `color2`, `price`, `rent`, `buyable`, `faction`, `fuel`,`Plate`) VALUES('%i', '%f', '%f', '%f', '%f', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%s')",
    model, x, y, z, a, color1, color2, price, rent, buyable, faction, 100, VehicleInfo[Iter_Count(Vehicles)][vPlate]);
    mysql_query(string);

    new ReturnedSQLID = mysql_insert_id();


    VehicleInfo[Iter_Count(Vehicles)][vSQLID] = ReturnedSQLID;
    VehicleInfo[Iter_Count(Vehicles)][Fuel] = 100;
    VehicleInfo[Iter_Count(Vehicles)][vModel] = model;
    VehicleInfo[Iter_Count(Vehicles)][vPos][0] = x;
    VehicleInfo[Iter_Count(Vehicles)][vPos][1] = y;
    VehicleInfo[Iter_Count(Vehicles)][vPos][2] = z;
    VehicleInfo[Iter_Count(Vehicles)][vPos][3] = a;
    VehicleInfo[Iter_Count(Vehicles)][vcolor1] = color1;
    VehicleInfo[Iter_Count(Vehicles)][vcolor2] = color2;
    VehicleInfo[Iter_Count(Vehicles)][vprice] = price;
    VehicleInfo[Iter_Count(Vehicles)][vrent] = rent;
    VehicleInfo[Iter_Count(Vehicles)][vbuyable] = buyable;
    VehicleInfo[Iter_Count(Vehicles)][vfaction] = faction;
    VehicleInfo[Iter_Count(Vehicles)][vOwner] = 0;
    VehicleInfo[Iter_Count(Vehicles)][vLock] = 0;
    VehicleInfo[Iter_Count(Vehicles)][vRented] = -1;

	SetVehicleNumberPlate(Iter_Count(Vehicles), VehicleInfo[Iter_Count(Vehicles)][vPlate]);
    SetVehicleToRespawn(Iter_Count(Vehicles));

    if(VehicleInfo[Iter_Count(Vehicles)][vbuyable] == 1) {
        new VehicleName[24];

        GetVehicleName(model, VehicleName, 24);

        format(string, sizeof(string), "{FF0000}%s\n{FF6666}Price:{FFFFFF}%s\n{FF6666}Fuel:{FFFFFF}%d", VehicleName, FormatMoney(price), 100  );
        BuyableVehicle[Iter_Count(Vehicles)] = Create3DTextLabel(string,COLOR_GREEN, 0,0,0,80.0,0);
        Attach3DTextLabelToVehicle( BuyableVehicle[Iter_Count(Vehicles)], Iter_Count(Vehicles), 0.0, 0.0, 0.0);
    }

    if(model == 435 || model == 450 || model == 591 || model == 584 ) {
        VehicleInfo[Iter_Count(Vehicles)][isTrailer] = true;
    }

}

stock LoadVehicles()
{
    printf("Loading vehicles...");
	new string[256];
    mysql_query("SELECT * FROM vehicles");
    mysql_store_result();
    new edata[33][30];
    while(mysql_fetch_row_format(string,"|"))
	{
        if(mysql_num_rows() == 0){  mysql_free_result(); continue; }
        explode(edata, string, "|");

        Itter_Add(Vehicles,Iter_Count(Vehicles)+1);

        VehicleInfo[Iter_Count(Vehicles)][vSQLID] = strval(edata[0]);
        VehicleInfo[Iter_Count(Vehicles)][vPos][0] = floatstr(edata[1]);
        VehicleInfo[Iter_Count(Vehicles)][vPos][1] = floatstr(edata[2]);
        VehicleInfo[Iter_Count(Vehicles)][vPos][2] = floatstr(edata[3]);
        VehicleInfo[Iter_Count(Vehicles)][vPos][3] = floatstr(edata[4]);
        VehicleInfo[Iter_Count(Vehicles)][vcolor1] = strval(edata[5]);
        VehicleInfo[Iter_Count(Vehicles)][vcolor2] = strval(edata[6]);
        VehicleInfo[Iter_Count(Vehicles)][vprice] = strval(edata[7]);
        VehicleInfo[Iter_Count(Vehicles)][vrent] = strval(edata[8]);
        VehicleInfo[Iter_Count(Vehicles)][vbuyable] = strval(edata[9]);
        VehicleInfo[Iter_Count(Vehicles)][vfaction] = strval(edata[10]);
        VehicleInfo[Iter_Count(Vehicles)][Fuel] = strval(edata[11]);
        VehicleInfo[Iter_Count(Vehicles)][vModel] = strval(edata[12]);
        VehicleInfo[Iter_Count(Vehicles)][vOwner] = strval(edata[13]);
        VehicleInfo[Iter_Count(Vehicles)][vLock] = strval(edata[14]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][0] = strval(edata[15]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][1] = strval(edata[16]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][2] = strval(edata[17]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][3] = strval(edata[18]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][4] = strval(edata[19]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][5] = strval(edata[20]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][6] = strval(edata[21]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][7] = strval(edata[22]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][8] = strval(edata[23]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][9] = strval(edata[24]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][10] = strval(edata[25]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][11] = strval(edata[26]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][12] = strval(edata[27]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][13] = strval(edata[28]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][14] = strval(edata[29]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][15] = strval(edata[30]);
        VehicleInfo[Iter_Count(Vehicles)][vMod][16] = strval(edata[31]);
        VehicleInfo[Iter_Count(Vehicles)][vRented] = -1;
        format(VehicleInfo[Iter_Count(Vehicles)][vPlate], 30, "%s", edata[32]);

		AddStaticVehicle(strval(edata[12]), floatstr(edata[1]), floatstr(edata[2]), floatstr(edata[3]), floatstr(edata[4]), VehicleInfo[Iter_Count(Vehicles)][vcolor1], VehicleInfo[Iter_Count(Vehicles)][vcolor2]);
		//printf("model: %i, %f %f %f", strval(edata[12]), floatstr(edata[1]), floatstr(edata[2]), floatstr(edata[3]));

        //printf("Vehicle Buyable: %d Itter: %d VehID: %d", VehicleInfo[Iter_Count(Vehicles)][vbuyable], Iter_Count(Vehicles), vehid);
        if(VehicleInfo[Iter_Count(Vehicles)][vbuyable] == 1) {
            new VehicleName[24];

            GetVehicleName(strval(edata[12]), VehicleName, 24);

            format(string, sizeof(string), "{FF0000}%s\n{FF6666}Price:{FFFFFF}%s\n{FF6666}Fuel:{FFFFFF}%d", VehicleName, FormatMoney(VehicleInfo[Iter_Count(Vehicles)][vprice]), 100  );
            BuyableVehicle[Iter_Count(Vehicles)] = Create3DTextLabel(string,COLOR_GREEN, 0,0,0,20, -1, 1);
            Attach3DTextLabelToVehicle( BuyableVehicle[Iter_Count(Vehicles)], Iter_Count(Vehicles), 0.0, 0.0, 0.0);
        }
		SetVehicleNumberPlate(Iter_Count(Vehicles), VehicleInfo[Iter_Count(Vehicles)][vPlate]);
    	SetVehicleToRespawn(Iter_Count(Vehicles));
    	new
			        engine,
			   		light,
			    	alarm,
					doors,
					bonnet,
					boot,
					objective;

    	GetVehicleParamsEx(Iter_Count(Vehicles), engine,light,alarm,doors,bonnet,boot,objective);
    	if(VehicleInfo[Iter_Count(Vehicles)][vLock] == 1)
    	{
    	    SetVehicleParamsEx(Iter_Count(Vehicles),engine,light,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
		}
	}
    printf("- Vehicle loading done.");
    mysql_free_result();
}

stock SavePlayerVehicle(vi)
{
	if(VehicleInfo[vi][vRented] > 0) return true;
	new string[612];
    format(string, sizeof(string), "UPDATE `vehicles` SET `vPos` = '%f', `vPos2` = '%f', `vPos3` = '%f'", VehicleInfo[vi][vPos][0], VehicleInfo[vi][vPos][1], VehicleInfo[vi][vPos][2], VehicleInfo[vi][vPos][3], VehicleInfo[vi][vprice], VehicleInfo[vi][vrent], VehicleInfo[vi][vbuyable], VehicleInfo[vi][vfaction],VehicleInfo[vi][vPos][0], VehicleInfo[vi][vPos][1], VehicleInfo[vi][vPos][2]);
    format(string, sizeof(string), "%s, `Fuel` = '%i', `Model` = '%i', `Owner` = '%i', `Lock` = '%i', `Mod1` = '%i', `Rent` = '%i', `Buyable` = '%i', `Faction` = '%i'", string,  VehicleInfo[vi][Fuel], VehicleInfo[vi][vModel], VehicleInfo[vi][vOwner], VehicleInfo[vi][vLock], VehicleInfo[vi][vMod][0],VehicleInfo[vi][vrent], VehicleInfo[vi][vbuyable], VehicleInfo[vi][vfaction]);
    format(string, sizeof(string), "%s, `Mod2` = '%i',`Mod3` = '%i',`Mod4` = '%i',`Mod5` = '%i',`Mod6` = '%i',`Mod7` = '%i',`Mod8` = '%i',`Mod9` = '%i',`Mod10` = '%i',`Color1` = '%i',`Color2` = '%i' ", string,   VehicleInfo[vi][vMod][1],VehicleInfo[vi][vMod][2],VehicleInfo[vi][vMod][3],VehicleInfo[vi][vMod][4],VehicleInfo[vi][vMod][5],VehicleInfo[vi][vMod][6],VehicleInfo[vi][vMod][7],VehicleInfo[vi][vMod][8], VehicleInfo[vi][vMod][9], VehicleInfo[vi][vcolor1], VehicleInfo[vi][vcolor2]);
    format(string, sizeof(string), "%s, `Mod11` = '%i' ,`Mod12` = '%i' ,`Mod13` = '%i' ,`Mod14` = '%i' ,`Mod15` = '%i' ,`Mod16` = '%i', `Mod17` = '%i', `vPos4` = '%f',  `Price` = '%i' WHERE `SQLID` = '%d'",string,VehicleInfo[vi][vMod][10],VehicleInfo[vi][vMod][11],VehicleInfo[vi][vMod][12],VehicleInfo[vi][vMod][13],VehicleInfo[vi][vMod][14],VehicleInfo[vi][vMod][15],VehicleInfo[vi][vMod][16], VehicleInfo[vi][vPos][3], VehicleInfo[vi][vprice], VehicleInfo[vi][vSQLID] );
    mysql_query(string);
    return true;
}

forward SaveComponent(playerid, vehicleid, componentid);
public SaveComponent(playerid, vehicleid,componentid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
        if (PlayerInfo[playerid][cSQLID] == VehicleInfo[vehicleid][vOwner])
		{
            for(new s=0; s<20; s++) {
                if(componentid == spoiler[s][0]) {
                    VehicleInfo[vehicleid][vMod][0] = componentid;
                }
            }
            for(new s=0; s<3; s++) {
                if(componentid == nitro[s][0]) {
                    VehicleInfo[vehicleid][vMod][1] = componentid;
                }
            }
            for(new s=0; s<23; s++) {
                if(componentid == fbumper[s][0]) {
                    VehicleInfo[vehicleid][vMod][2] = componentid;
                }
            }
            for(new s=0; s<22; s++) {
                if(componentid == rbumper[s][0]) {
                    VehicleInfo[vehicleid][vMod][3] = componentid;
                }
            }
            for(new s=0; s<28; s++) {
                if(componentid == exhaust[s][0]) {
                    VehicleInfo[vehicleid][vMod][4] = componentid;
                }
            }
            for(new s=0; s<2; s++) {
                if(componentid == bventr[s][0]) {
                    VehicleInfo[vehicleid][vMod][5] = componentid;
                }
            }
            for(new s=0; s<2; s++) {
                if(componentid == bventl[s][0]) {
                    VehicleInfo[vehicleid][vMod][6] = componentid;
                }
            }
            for(new s=0; s<4; s++) {
                if(componentid == bscoop[s][0]) {
                    VehicleInfo[vehicleid][vMod][7] = componentid;
                }
            }
            for(new s=0; s<17; s++) {
                if(componentid == rscoop[s][0]) {
                    VehicleInfo[vehicleid][vMod][8] = componentid;
                }
            }
            for(new s=0; s<21; s++) {
                if(componentid == lskirt[s][0]) {
                    VehicleInfo[vehicleid][vMod][9] = componentid;
                }
            }
            for(new s=0; s<21; s++) {
                if(componentid == rskirt[s][0]) {
                    VehicleInfo[vehicleid][vMod][10] = componentid;
                }
            }
            for(new s=0; s<1; s++) {
                if(componentid == hydraulics[s][0]) {
                    VehicleInfo[vehicleid][vMod][11] = componentid;
                }
            }
            for(new s=0; s<1; s++) {
                if(componentid == base[s][0]) {
                    VehicleInfo[vehicleid][vMod][12] = componentid;
                }
            }
            for(new s=0; s<4; s++) {
                if(componentid == rbbars[s][0]) {
                    VehicleInfo[vehicleid][vMod][13] = componentid;
                }
            }
            for(new s=0; s<2; s++) {
                if(componentid == fbbars[s][0]) {
                    VehicleInfo[vehicleid][vMod][14] = componentid;
                }
            }
            for(new s=0; s<17; s++) {
                if(componentid == wheels[s][0]) {
                    VehicleInfo[vehicleid][vMod][15] = componentid;
                }
            }
            for(new s=0; s<2; s++) {
                if(componentid == lights[s][0]) {
                    VehicleInfo[vehicleid][vMod][16] = componentid;
                }
            }
            return 1;
        }
        SavePlayerVehicle(vehicleid);
    }
    return 0;
}


stock ModVehicle(vehicleid)
{
    for(new i = 0; i<17; i++)
	{
        AddVehicleComponent(vehicleid, VehicleInfo[vehicleid][vMod][i]);
    }
}


stock FormatMoney(Float:amount, delimiter[2]=",")
{
	#define MAX_MONEY_STRING 16
    new txt[MAX_MONEY_STRING];
    format(txt, MAX_MONEY_STRING, "$%d", floatround(amount));
    new l = strlen(txt);
    if (amount < 0) {
        if (l > 5) strins(txt, delimiter, l-3);
        if (l > 8) strins(txt, delimiter, l-6);
        if (l > 11) strins(txt, delimiter, l-9);
    }
    else {
        if (l > 4) strins(txt, delimiter, l-3);
        if (l > 7) strins(txt, delimiter, l-6);
        if (l > 10) strins(txt, delimiter, l-9);
    }
    return txt;
}

stock ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid)) {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        GetPlayerPos(targetid, posx, posy, posz);
        tempposx = (oldposx -posx);
        tempposy = (oldposy -posy);
        tempposz = (oldposz -posz);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) {
            if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(targetid)) {
                return 1;
            }
        }
    }
    return 0;
}

stock GetVehicleName(modelid,name[],namesize)
{
    if(modelid < 400 || modelid > 611) return 0;
    modelid -= 400;
    for(new i, len = strlen(VehicleNames[modelid]); i < len && i < namesize; i++)
        name[i] = VehicleNames[modelid][i];
    return 1;
}

stock GetClosestVeh(playerid, Float:dis)
{
    new Float:X, Float:Y, Float:Z;
    if(GetPlayerPos(playerid, X, Y, Z)) {
        new vehicleid = INVALID_VEHICLE_ID;
        for(new v, Float:temp, Float:VX, Float:VY, Float:VZ; v != MAX_VEHICLES; v++) {
            if(GetVehiclePos(v, VX, VY, VZ)) {
                VX -= X, VY -= Y, VZ -= Z;
                temp = VX * VX + VY * VY + VZ * VZ;
                if(temp < dis) dis = temp, vehicleid = v;
            }
        }
        dis = floatpower(dis, 0.5);
        return vehicleid;
    }
    return INVALID_VEHICLE_ID;
}

stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (IsPlayerInAnyVehicle(playerid)) {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    else {
        GetPlayerFacingAngle(playerid, a);
    }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}

stock explode(aExplode[][], const sSource[], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])
{
    new
        iNode,
        iPointer,
        iPrevious = -1,
        iDelimiter = strlen(sDelimiter);

    while(iNode < iVertices) {
        iPointer = strfind(sSource, sDelimiter, false, iPointer);

        if(iPointer == -1) {
            strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
            break;
        }
        else {
            strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
        }

        iPrevious = (iPointer += iDelimiter);
        ++iNode;
    }

    return iPrevious;
}

LoadTextDraws()
{
	Clock = Text:INVALID_TEXT_DRAW;
	Clock = TextDrawCreate(557.000000, 20.000000, "17:29");
	TextDrawBackgroundColor(Clock, 255);
	TextDrawFont(Clock, 2);
	TextDrawLetterSize(Clock, 0.359999, 2.499999);
	TextDrawColor(Clock, -1);
	TextDrawSetOutline(Clock, 1);
	TextDrawSetProportional(Clock, 1);

    Tip = INVALID_TEXT_DRAW;
	Tip = TextDrawCreate(240.000000, 422.000000, "Want to learn new fighting styles?~n~You can learn fighting styles in business(gym)");
	TextDrawBackgroundColor(Tip, 255);
	TextDrawFont(Tip, 1);
	TextDrawLetterSize(Tip, 0.230000, 1.000000);
	TextDrawColor(Tip, -1);
	TextDrawSetOutline(Tip, 0);
	TextDrawSetProportional(Tip, 1);
	TextDrawSetShadow(Tip, 1);
	TextDrawUseBox(Tip, 1);
	TextDrawBoxColor(Tip, 50);
	TextDrawTextSize(Tip, 470.000000, 20.000000);

}

stock UpdateVehicleCPU(playerid)
{
	if(GetPVarInt(playerid, "VEHICLE_CPU") == 1)
	{
		//if(GetPVarInt(playerid, "SHOW_SPEED") == 1)
		//{
        TextDrawDestroy(SpeedHud[playerid]);
        TextDrawDestroy(VehName[playerid]);
		SpeedHud[playerid] = Text:INVALID_TEXT_DRAW;
		VehName[playerid] = Text:INVALID_TEXT_DRAW;
		//}
	    new engine,light,alarm,doors,bonnet,boot,objective;
	    new VehID = GetPlayerVehicleID(playerid);
	    new e_string[26];
	    new l_string[26];
	    new d_string[26];
	    new b_string[26];
	    new bo_string[26];
	    new big_str[128];
	    GetVehicleParamsEx(VehID,engine,light,alarm,doors,bonnet,boot,objective);
		if(engine == 1)
		{
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 1)
		   {
			 e_string = "~g~~<~on~>~";
	       }
	       else
	       {
			 e_string = "~g~on";
	       }
		}
		else
		{
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 1)
		   {
			 e_string = "~r~~<~off~>~";
	       }
	       else
	   	   {
			 e_string = "~r~off";
	       }
		}
	    if(light == -1 || light == 0)
	    {
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 2)
		   {
			 l_string = "~r~~<~off~>~";
	       }
	       else
	       {
			 l_string = "~r~off";
		   }
		}
		else
		{
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 2)
		   {
			 l_string = "~g~~<~on~>~";
	       }
	       else
	       {
			 l_string = "~g~on";
		   }
		}
	    if(VehicleInfo[VehID][vLock] == 1)
	    {
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 3)
		   {
			 d_string = "~r~~<~closed~>~";
	       }
	       else
	       {
			 d_string = "~r~closed";
		   }
		}
		else
		{
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 3)
		   {
			 d_string = "~g~~<~open~>~";
	       }
	       else
	       {
			 d_string = "~g~open";
		   }
		}
	    if(bonnet == -1 || bonnet == 0)
	    {
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 4)
		   {
			 b_string = "~r~~<~closed~>~";
	       }
	       else
	       {
			 b_string = "~r~closed";
		   }
		}
		else
		{
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 4)
		   {
			 b_string = "~g~~<~open~>~";
	       }
	       else
	       {
			 b_string = "~g~open";
		   }
		}
	    if(boot == -1 || boot == 0)
	    {
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 5)
		   {
			 bo_string = "~r~~<~closed~>~";
	       }
	       else
	       {
			 bo_string = "~r~closed";
		   }
		}
		else
		{
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 5)
		   {
			 bo_string = "~g~~<~open~>~";
	       }
	       else
	       {
			 bo_string = "~g~open";
		   }
		}
		SpeedHud[playerid] = INVALID_TEXT_DRAW;
		format(big_str, 128, "~n~Engine: %s~w~~n~Lights: %s~w~~n~Lock: %s~n~~w~Boot: %s~n~~w~Bonnet: %s", e_string, l_string, d_string, b_string, bo_string);
		//TextDrawSetString(VehicleCPU[playerid], big_str);
		SpeedHud[playerid] = TextDrawCreate(460.000000, 290.000000, big_str);
		TextDrawBackgroundColor(SpeedHud[playerid], 255);
		TextDrawFont(SpeedHud[playerid], 2);
		TextDrawLetterSize(SpeedHud[playerid], 0.189998, 1.000000);
		TextDrawColor(SpeedHud[playerid], -1);
		TextDrawSetOutline(SpeedHud[playerid], 0);
		TextDrawSetProportional(SpeedHud[playerid], 1);
		TextDrawSetShadow(SpeedHud[playerid], 1);
		TextDrawUseBox(SpeedHud[playerid], 1);
		TextDrawBoxColor(SpeedHud[playerid], 50);
		TextDrawTextSize(SpeedHud[playerid], 630.000000, 0.000000);
		TextDrawShowForPlayer(playerid, SpeedHud[playerid]);

		new VehicleName[24];
	    GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);

		VehName[playerid] = TextDrawCreate(458.000000, 271.000000, VehicleName);
		TextDrawBackgroundColor(VehName[playerid], 255);
		TextDrawFont(VehName[playerid], 0);
		TextDrawLetterSize(VehName[playerid], 0.720000, 2.700000);
		TextDrawColor(VehName[playerid], -1);
		TextDrawSetOutline(VehName[playerid], 0);
		TextDrawSetProportional(VehName[playerid], 1);
		TextDrawSetShadow(VehName[playerid], 1);

		TextDrawShowForPlayer(playerid, VehName[playerid]);
		return true;
    }
    if(GetPVarInt(playerid, "VEHICLE_CPU") == 2)
    {
		if(HouseTitle[playerid] != Text:INVALID_TEXT_DRAW && HouseMenu[playerid] != Text:INVALID_TEXT_DRAW )
		{
			TextDrawDestroy(HouseTitle[playerid]);
			TextDrawDestroy(HouseMenu[playerid]);
	   		HouseTitle[playerid] = Text:INVALID_TEXT_DRAW;
			HouseMenu[playerid] = Text:INVALID_TEXT_DRAW;
		}

		new hid = GetPVarInt(playerid, "HOUSEE");
		new m_str[128];
		new s_str[24];
		if(HouseInfo[hid][hLocked] == 1)
		{
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 1)
		   {
			  s_str = "~r~~<~locked~>~";
	       }
	       else
	       {
			  s_str = "~r~locked";
	       }
	    }
		if(HouseInfo[hid][hLocked] == 0)
		{
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 1)
		   {
			  s_str = "~g~~<~unlocked~>~";
	       }
	       else
	       {
			  s_str = "~g~unlocked";
	       }
	    }

		format(m_str, 128, "~n~Doors: %s", s_str);
		
		SetPVarInt(playerid, "SHOW_HOUSE", 1);
		HouseMenu[playerid] = TextDrawCreate(500.000000, 130.000000, m_str);
		TextDrawBackgroundColor(HouseMenu[playerid], 255);
		TextDrawFont(HouseMenu[playerid], 2);
		TextDrawLetterSize(HouseMenu[playerid], 0.200000, 1.000000);
		TextDrawColor(HouseMenu[playerid], -1);
		TextDrawSetOutline(HouseMenu[playerid], 0);
		TextDrawSetProportional(HouseMenu[playerid], 1);
		TextDrawSetShadow(HouseMenu[playerid], 1);
		TextDrawUseBox(HouseMenu[playerid], 1);
		TextDrawBoxColor(HouseMenu[playerid], 50);
		TextDrawTextSize(HouseMenu[playerid], 610.000000, 0.000000);
		
		HouseTitle[playerid] = TextDrawCreate(502.000000, 125.000000, "House panel");
		TextDrawBackgroundColor(HouseTitle[playerid], 255);
		TextDrawFont(HouseTitle[playerid], 3);
		TextDrawLetterSize(HouseTitle[playerid], 0.300000, 1.200000);
		TextDrawColor(HouseTitle[playerid], 872415231);
		TextDrawSetOutline(HouseTitle[playerid], 1);
		TextDrawSetProportional(HouseTitle[playerid], 1);
		
		TextDrawShowForPlayer(playerid, HouseMenu[playerid]);
		TextDrawShowForPlayer(playerid, HouseTitle[playerid]);
		return true;
    }
    return true;
}

stock UpdateSpeedo(playerid, VehID)
{
	if(GetPVarInt(playerid, "VEHICLE_CPU") == 1) return true;
	
	//SpeedHud[playerid] = TextDrawCreate(460.000000, 290.000000, "_");
	//VehName[playerid] = TextDrawCreate(458.000000, 271.000000, "_");
	
	if(VehName[playerid] != Text:INVALID_TEXT_DRAW && SpeedHud[playerid] != Text:INVALID_TEXT_DRAW)
	{
		TextDrawDestroy(SpeedHud[playerid]);
		TextDrawDestroy(VehName[playerid]);
		VehName[playerid] = Text:INVALID_TEXT_DRAW;
		SpeedHud[playerid] = Text:INVALID_TEXT_DRAW;
	}
	
	new Float:health, Float:vVelocity[3];
	new km_str[22];
	new e_str[29];
	new f_str[25];
	new sp_str[130];
	GetVehicleHealth(VehID, health);
 	GetVehicleVelocity(VehID, vVelocity[0], vVelocity[1], vVelocity[2]);
  	new Float: vSpeed = floatsqroot(floatpower(vVelocity[0], 2) + floatpower(vVelocity[1], 2) + floatpower(vVelocity[2], 2)) * 99;
	switch(VehicleInfo[VehID][Fuel])
	{
		  case 96..100:
		  {
                	   f_str = "~g~IIIIIIIIIIIIIIIIIII";
		  }
		  case 90..95:
		  {
                	   f_str = "~g~IIIIIIIIIIIIIIIIII";
		  }
		  case 85..89:
		  {
                	   f_str = "~g~IIIIIIIIIIIIIIIII";
		  }
		  case 80..84:
		  {
                	   f_str = "~g~IIIIIIIIIIIIIIII";
		  }
		  case 75..79:
		  {
                	   f_str = "~g~IIIIIIIIIIIIIII";
		  }
		  case 70..74:
		  {
                	   f_str = "~g~IIIIIIIIIIIIII";
		  }
		  case 65..69:
		  {
                	   f_str = "~g~IIIIIIIIIIIII";
		  }
		  case 60..64:
		  {
                	   f_str = "~y~IIIIIIIIIIII";
		  }
		  case 55..59:
		  {
                	   f_str = "~y~IIIIIIIIIIII";
		  }
		  case 50..54:
		  {
                	   f_str = "~y~IIIIIIIIIII";
		  }
		  case 45..49:
		  {
                	   f_str = "~y~IIIIIIIIII";
		  }
		  case 40..44:
		  {
                	   f_str = "~y~IIIIIIIII";
		  }
		  case 35..39:
		  {
                	   f_str = "~y~IIIIIIII";
		  }
		  case 30..34:
		  {
                	   f_str = "~y~IIIIIII";
		  }
		  case 25..29:
		  {
                	   f_str = "~y~IIIIII";
		  }
		  case 20..24:
		  {
                	   f_str = "~y~IIIIII";
		  }
		  case 15..19:
		  {
                	   f_str = "~r~IIIII";
		  }
		  case 10..14:
		  {
                	   f_str = "~r~IIII";
		  }
		  case 5..9:
		  {
                	   f_str = "~r~III";
		  }
		  case 1..4:
		  {
                	   f_str = "~r~I";
		  }
		  case 0:
		  {
                	   f_str = "~r~No Fuel";
		  }
	}
	vSpeed = vSpeed * 1.4;
	new vvSpeed = floatround(vSpeed, floatround_round);
	switch(vvSpeed)
	{
		 case 0..50:
		 {
		   format(km_str, 22, "~w~%0.0fkm/h", vSpeed);
		 }
		 case 51..300:
		 {
		   format(km_str, 22, "~r~%0.0fkm/h", vSpeed);
		 }
	}
	new hhealth = floatround(health, floatround_round);
	switch(hhealth)
	{
		  case 960..1000:
		  {
                	   e_str = "~g~IIIIIIIIIIIIIIIIIII";
		  }
		  case 900..950:
		  {
                	   e_str = "~g~IIIIIIIIIIIIIIIIII";
		  }
		  case 850..899:
		  {
                	   e_str = "~g~IIIIIIIIIIIIIIIII";
		  }
		  case 800..849:
		  {
                	   e_str = "~g~IIIIIIIIIIIIIIII";
		  }
		  case 750..799:
		  {
                	   e_str = "~g~IIIIIIIIIIIIIII";
		  }
		  case 700..749:
		  {
                	   e_str = "~g~IIIIIIIIIIIIII";
		  }
		  case 650..699:
		  {
                	   e_str = "~g~IIIIIIIIIIIII";
		  }
		  case 600..649:
		  {
                	   e_str = "~y~IIIIIIIIIIII";
		  }
		  case 550..599:
		  {
                	   e_str = "~y~IIIIIIIIIIII";
		  }
		  case 500..549:
		  {
                	   e_str = "~y~IIIIIIIIIII";
		  }
		  case 450..499:
		  {
                	   e_str = "~y~IIIIIIIIII";
		  }
		  case 400..449:
		  {
                	   e_str = "~y~IIIIIIIII";
		  }
		  case 350..399:
		  {
                	   e_str = "~r~IIIIIIII";
		  }
		  case 300..349:
		  {
                	   e_str = "~r~IIIIIII";
		  }
		  case 250..299:
		  {
                	   e_str = "~r~IIIIII";
		  }
		  case 200..249:
		  {
                	   e_str = "~r~IIIIII";
		  }
		  case 150..199:
		  {
                	   e_str = "~r~IIIII";
		  }
		  case 100..149:
		  {
                	   e_str = "~r~IIII";
		  }
		  case 50..99:
		  {
                	   e_str = "~r~III";
		  }
		  case 10..49:
		  {
                	   e_str = "~r~I";
		  }
		  case 0:
		  {
                	   e_str = "~r~No Fuel";
		  }
	}/*
	switch(hhealth)
	{
		 case 700..1001:
		 {
			  e_str = "~g~Good";
		 }
		 case 301..699:
		 {
			  e_str = "~y~Bad";
		 }
		 case 0..300:
		 {
			  e_str = "~r~Broken";
		 }
	}*/
	
	SetPVarInt(playerid, "SHOW_SPEED", 1);
	format(sp_str, 130, "~n~Speed:%s~n~~w~Fuel:   %s~w~~n~Engine:%s", km_str, f_str, e_str);
	SpeedHud[playerid] = TextDrawCreate(460.000000, 290.000000, sp_str);
	TextDrawBackgroundColor(SpeedHud[playerid], 255);
	TextDrawFont(SpeedHud[playerid], 2);
	TextDrawLetterSize(SpeedHud[playerid], 0.189998, 1.000000);
	TextDrawColor(SpeedHud[playerid], -1);
	TextDrawSetOutline(SpeedHud[playerid], 0);
	TextDrawSetProportional(SpeedHud[playerid], 1);
	TextDrawSetShadow(SpeedHud[playerid], 1);
	TextDrawUseBox(SpeedHud[playerid], 1);
	TextDrawBoxColor(SpeedHud[playerid], 50);
	TextDrawTextSize(SpeedHud[playerid], 630.000000, 0.000000);

	new VehicleName[24];
    GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
    
	VehName[playerid] = TextDrawCreate(458.000000, 271.000000, VehicleName);
	TextDrawBackgroundColor(VehName[playerid], 255);
	TextDrawFont(VehName[playerid], 0);
	TextDrawLetterSize(VehName[playerid], 0.720000, 2.700000);
	TextDrawColor(VehName[playerid], -1);
	TextDrawSetOutline(VehName[playerid], 0);
	TextDrawSetProportional(VehName[playerid], 1);
	TextDrawSetShadow(VehName[playerid], 1);
	
	TextDrawShowForPlayer(playerid, VehName[playerid]);
	TextDrawShowForPlayer(playerid, SpeedHud[playerid]);
	return true;
}

public SetPlayerSpeedCap( playerid, Float:value )
{
	if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
		g_fSpeedCap[ playerid ] = value;
}

public DisablePlayerSpeedCap( playerid )
{
	if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
		g_fSpeedCap[ playerid ] = 0.0;
}

stock ShowInfo(playerid, text[])
{
	new string[128];
    SetPVarInt(playerid, "InfoBar", 1);
    format(string, sizeof(string), "~>~ %s", text);
    
	if(InfoBar[playerid] != Text:INVALID_TEXT_DRAW) // avoid bugging
	{
		 TextDrawDestroy(InfoBar[playerid]);
		 InfoBar[playerid] = Text:INVALID_TEXT_DRAW;
	}

    SetPVarInt(playerid, "INFO_SHOWING", 1);
	InfoBar[playerid] = TextDrawCreate(2.000000, 303.000000, string);
    TextDrawBackgroundColor(InfoBar[playerid], 255);
    TextDrawFont(InfoBar[playerid], 1);
    TextDrawLetterSize(InfoBar[playerid], 0.239999, 1.100000);
    TextDrawColor(InfoBar[playerid], -1);
    TextDrawSetOutline(InfoBar[playerid], 1);
    TextDrawSetProportional(InfoBar[playerid], 1);
    TextDrawUseBox(InfoBar[playerid], 1);
    TextDrawBoxColor(InfoBar[playerid], -236);
    TextDrawTextSize(InfoBar[playerid], 228.000000, -197.000000);
    
    TextDrawShowForPlayer(playerid, InfoBar[playerid]);
    
}

stock ShowInfo2(playerid, text[])
{
    SetPVarInt(playerid, "InfoBar", 1);
    SetPVarInt(playerid, "INFO_SHOWING2", 1);
    InfoText[playerid] = TextDrawCreate(22.000000, 130.000000, text);
	TextDrawBackgroundColor(InfoText[playerid], 255);
	TextDrawFont(InfoText[playerid], 1);
	TextDrawLetterSize(InfoText[playerid], 0.290000, 1.000000);
	TextDrawColor(InfoText[playerid], -1);
	TextDrawSetOutline(InfoText[playerid], 1);
	TextDrawSetProportional(InfoText[playerid], 1);
	TextDrawUseBox(InfoText[playerid], 1);
	TextDrawBoxColor(InfoText[playerid], 100);
	TextDrawTextSize(InfoText[playerid], 190.000000, 0.000000);
	
    TextDrawShowForPlayer(playerid, InfoText[playerid]);
}

stock GetUserDBID(name[])
{
	new idd;
    format(query, sizeof(query), "SELECT `id` FROM characters WHERE name = '%s'", name);
    mysql_query(query);
    mysql_store_result();
 	idd = mysql_fetch_int();
 	mysql_free_result();
 	return idd;
 }

stock GetUserDBName(userid)
{
    new UserName[24];

    format(query, sizeof(query), "SELECT `name` FROM characters WHERE id = '%d'", userid);
    mysql_query(query);
    mysql_store_result();

    mysql_fetch_row_format(UserName);

    mysql_free_result();

    return UserName;
}

stock GetPlayerWeaponName(weaponid)
{
    return WeaponNames[weaponid];
}

stock RemovePlayerWeapon(playerid, weaponid);
public RemovePlayerWeapon(playerid, weaponid)
{
    new plyWeapons[12] = 0;
    new plyAmmo[12] = 0;
    for(new sslot = 0; sslot != 12; sslot++) {
        new wep, ammo;
        GetPlayerWeaponData(playerid, sslot, wep, ammo);
        if(wep != weaponid && ammo != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot], plyAmmo[sslot]);
    }
    ResetPlayerWeapons(playerid);
    for(new sslot = 0; sslot != 12; sslot++) {
        if(plyAmmo[sslot] != 0) GivePlayerWeapon(playerid, plyWeapons[sslot], plyAmmo[sslot]);
    }
    return 1;
}

stock SaveInventory(playerid)
{
	new string[200];
    for(new item;item<MAX_ITEMS;item++)
	{
        if(!strlen(_GetItemNamePVar(playerid,item))||!_GetItemAmountPVar(playerid,item))continue;
        format(string, 200, "INSERT INTO inventory (CharacterID, Itemname, Amount) VALUES('%d','%s','%d')",PlayerInfo[playerid][cSQLID], _GetItemNamePVar(playerid,item),_GetItemAmountPVar(playerid,item));
        mysql_query(string);
    }
    mysql_free_result();
    return 1;
}


stock LoadInventory(playerid)
{
    new itemname[24] ,amount, string[128];                     /*`Itemname`,`Amount` FROM `inventory`*/
    format(string, sizeof(string), "SELECT `Itemname`,`Amount` FROM `inventory`  WHERE `CharacterID` = '%d'",PlayerInfo[playerid][cSQLID]);
    mysql_query(string);
    mysql_store_result();

    while(mysql_fetch_row_format(line,"|"))
	{
        sscanf(line, "p<|>s[24]i", itemname,amount);
        AddItem(playerid, itemname, amount);
        format(string, 128, "DELETE FROM inventory WHERE CharacterID = '%d' AND Itemname = '%s'", PlayerInfo[playerid][cSQLID], itemname);
        mysql_query(string);
    }
    mysql_free_result();
}

forward UpdateTIP();
public UpdateTIP()
{
    TextDrawHideForAll(Tip);
    new tip = random(8);
    switch(tip)
    {
		case 0:
		{
			 TextDrawSetString(Tip, "~y~Want new fighting styles?~n~~w~You can learn fighting style at gym type ~g~businesses!");
		}
		case 1:
		{
			 TextDrawSetString(Tip, "~y~Did you know that we have forums?~n~~w~www.myforums.com");
		}
		case 2:
		{
			 TextDrawSetString(Tip, "~y~Want to create an official gang/faction?~n~~w~Search for application: www.myforums.com");
		}
		case 3:
		{
			 TextDrawSetString(Tip, "~y~Did you know that you can disable this?~n~~w~Type /hidetips to hide this.");
		}
		case 4:
		{
			 TextDrawSetString(Tip, "~y~Want to change your fighting style?~n~~w~Type ~y~/fightingstyle~w~ to change it.");
		}
		case 5:
		{
			 TextDrawSetString(Tip, "~y~Want to change character without logging off?~n~~w~Type ~y~/changecharacter~w~ to change it.");
		}
		case 6:
		{
			 TextDrawSetString(Tip, "~y~You can turn your vehicle's on lights / open trunk etc..~n~~w~Type ~g~/vcp~w~ while you're in a vehicle.");
		}
		case 7:
		{
			 TextDrawSetString(Tip, "~y~We are looking for admins~n~~w~If you think you meet our requirements, you may apply on our forums.");
		}
	}
	foreach(Player, playerid)
	{
		 if(GetPVarInt(playerid, "TIPS") == 0 && IsPlayerSpawned(playerid))
		 {
			   TextDrawShowForPlayer(playerid, Tip);
		 }
	}
}

stock GetPlayerNameEx(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}

stock HideLogBox(playerid)
{
	TextDrawDestroy(Textdraw0[playerid]);
	TextDrawDestroy(Textdraw1[playerid]);
	TextDrawDestroy(Textdraw2[playerid]);
	TextDrawDestroy(Textdraw3[playerid]);
	TextDrawDestroy(Textdraw4[playerid]);
	TextDrawDestroy(Textdraw5[playerid]);
	Textdraw0[playerid] = Text:INVALID_TEXT_DRAW;
	Textdraw1[playerid] = Text:INVALID_TEXT_DRAW;
	Textdraw2[playerid] = Text:INVALID_TEXT_DRAW;
	Textdraw3[playerid] = Text:INVALID_TEXT_DRAW;
	Textdraw4[playerid] = Text:INVALID_TEXT_DRAW;
	Textdraw5[playerid] = Text:INVALID_TEXT_DRAW;
}

stock ShowLogBox(playerid)
{
	Textdraw0[playerid] = TextDrawCreate(200.000000, 75.000000, "Andreas Role Play~n~~n~");
	TextDrawBackgroundColor(Textdraw0[playerid], 255);
	TextDrawFont(Textdraw0[playerid], 2);
	TextDrawLetterSize(Textdraw0[playerid], 0.480000, 3.000000);
	TextDrawColor(Textdraw0[playerid], -1027423489);
	TextDrawSetOutline(Textdraw0[playerid], 0);
	TextDrawSetProportional(Textdraw0[playerid], 1);
	TextDrawSetShadow(Textdraw0[playerid], 1);
	TextDrawUseBox(Textdraw0[playerid], 1);
	TextDrawBoxColor(Textdraw0[playerid], 50);
	TextDrawTextSize(Textdraw0[playerid], 410.000000, 0.000000);

	Textdraw1[playerid] = TextDrawCreate(360.000000, 99.000000, "Version 0.1");
	TextDrawBackgroundColor(Textdraw1[playerid], 255);
	TextDrawFont(Textdraw1[playerid], 1);
	TextDrawLetterSize(Textdraw1[playerid], 0.220000, 1.100000);
	TextDrawColor(Textdraw1[playerid], -855638072);
	TextDrawSetOutline(Textdraw1[playerid], 1);
	TextDrawSetProportional(Textdraw1[playerid], 1);

	Textdraw2[playerid] = TextDrawCreate(408.000000, 30.000000, "I");
	TextDrawBackgroundColor(Textdraw2[playerid], 255);
	TextDrawFont(Textdraw2[playerid], 2);
	TextDrawLetterSize(Textdraw2[playerid], 0.500000, 14.800003);
	TextDrawColor(Textdraw2[playerid], -1);
	TextDrawSetOutline(Textdraw2[playerid], 0);
	TextDrawSetProportional(Textdraw2[playerid], 1);
	TextDrawSetShadow(Textdraw2[playerid], 1);

	Textdraw3[playerid] = TextDrawCreate(193.000000, 28.000000, "I");
	TextDrawBackgroundColor(Textdraw3[playerid], 255);
	TextDrawFont(Textdraw3[playerid], 2);
	TextDrawLetterSize(Textdraw3[playerid], 0.500000, 15.000000);
	TextDrawColor(Textdraw3[playerid], -1);
	TextDrawSetOutline(Textdraw3[playerid], 0);
	TextDrawSetProportional(Textdraw3[playerid], 1);
	TextDrawSetShadow(Textdraw3[playerid], 1);

	Textdraw4[playerid] = TextDrawCreate(109.000000, 65.000000, "I");
	TextDrawBackgroundColor(Textdraw4[playerid], 255);
	TextDrawFont(Textdraw4[playerid], 2);
	TextDrawLetterSize(Textdraw4[playerid], 32.600074, 1.000000);
	TextDrawColor(Textdraw4[playerid], -1);
	TextDrawSetOutline(Textdraw4[playerid], 0);
	TextDrawSetProportional(Textdraw4[playerid], 1);
	TextDrawSetShadow(Textdraw4[playerid], 1);

	Textdraw5[playerid] = TextDrawCreate(109.000000, 125.000000, "I");
	TextDrawBackgroundColor(Textdraw5[playerid], 255);
	TextDrawFont(Textdraw5[playerid], 2);
	TextDrawLetterSize(Textdraw5[playerid], 32.600074, 1.000000);
	TextDrawColor(Textdraw5[playerid], -1);
	TextDrawSetOutline(Textdraw5[playerid], 0);
	TextDrawSetProportional(Textdraw5[playerid], 1);
	TextDrawSetShadow(Textdraw5[playerid], 1);
	
	TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
	TextDrawShowForPlayer(playerid, Textdraw1[playerid]);
	TextDrawShowForPlayer(playerid, Textdraw2[playerid]);
	TextDrawShowForPlayer(playerid, Textdraw3[playerid]);
	TextDrawShowForPlayer(playerid, Textdraw4[playerid]);
	TextDrawShowForPlayer(playerid, Textdraw5[playerid]);
}

UpdateClock()
{
	new clockstr[28];
	new hour = 0;
	minute = 0;
	new seconds = 0;
	gettime(hour, minute, seconds);
	format(clockstr, 28, "%02d:%02d", hour, minute);
	TextDrawSetString(Clock, clockstr);
	SetWorldTime(hour);
}

